package com.ysd.twocrm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ysd.twocrm.entity.Logs;
import com.ysd.twocrm.mapper.LogsMapper;
import com.ysd.twocrm.service.LogsService;
import com.ysd.twocrm.utils.LayuiUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LogsServiceImpl implements LogsService {
    @Autowired
    private LogsMapper logsMapper;
    @Override
    public LayuiUtils<Logs> LOGS_LAYUI_UTILS(Integer page, Logs l) {
        Page<Logs> page1=new Page<Logs>(page,10);
        QueryWrapper<Logs> queryWrapper=new QueryWrapper<Logs>();
        queryWrapper.orderByDesc("id");
        if(l.getUserId()!=null){
            queryWrapper.eq("userId",l.getUserId());
        }
        if(l.getUserName()!=null){
            queryWrapper.like("userName",l.getUserName());
        }
        Page<Logs> logsPage = logsMapper.selectPage(page1, queryWrapper);
        LayuiUtils<Logs> logsLayuiUtils=new LayuiUtils<Logs>();
        logsLayuiUtils.setData(logsPage.getRecords());
        logsLayuiUtils.setCount(logsPage.getTotal());
        return logsLayuiUtils;
    }
}
